//
//  HRZFeatureChoseTopCell.m
//  EMarket
//
//  Created by 石头 on 2018/5/18.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZFeatureChoseTopCell.h"

@interface HRZFeatureChoseTopCell()

/* 取消 */
@property (strong , nonatomic)UIButton *crossButton;

@end

@implementation HRZFeatureChoseTopCell

#pragma mark - Intial
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addSubview:self.crossButton];
        [self addSubview:self.goodImageView];
        [self addSubview:self.goodPriceLabel];
        [self addSubview:self.chooseAttLabel];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [_crossButton mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.right.mas_equalTo(self)setOffset:-HRZMargin];
        [make.top.mas_equalTo(self)setOffset:HRZMargin];
        make.size.mas_equalTo(CGSizeMake(35, 35));
    }];
    
    [_goodImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(self)setOffset:HRZMargin];
        [make.top.mas_equalTo(self)setOffset:HRZMargin];
        make.size.mas_equalTo(CGSizeMake(80, 80));
    }];
    
    [_goodPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(self->_goodImageView.mas_right)setOffset:HRZMargin];
        [make.top.mas_equalTo(self->_goodImageView)setOffset:HRZMargin];
    }];
    
    [_chooseAttLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self->_goodPriceLabel);
        make.right.mas_equalTo(self->_crossButton.mas_left);
        [make.top.mas_equalTo(self->_goodPriceLabel.mas_bottom)setOffset:5];
    }];
    
}


#pragma mark - ----  eventRespones  ----
- (void)crossButtonClick
{
    !_crossButtonClickBlock ?: _crossButtonClickBlock();
}

#pragma mark - Setter Getter Methods

- (UILabel *)chooseAttLabel{
    if (!_chooseAttLabel) {
        _chooseAttLabel = [UILabel new];
        _chooseAttLabel.numberOfLines = 2;
        _chooseAttLabel.font = PFR14Font;
    }
    return _chooseAttLabel;
}

- (UILabel *)goodPriceLabel{
    if (!_goodPriceLabel) {
        _goodPriceLabel = [UILabel new];
        _goodPriceLabel.font = PFR18Font;
        _goodPriceLabel.textColor = [UIColor redColor];
    }
    return _goodPriceLabel;
}

- (UIButton *)crossButton{
    if (!_crossButton) {
        _crossButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_crossButton setImage:[UIImage imageNamed:@"icon_cha"] forState:0];
        [_crossButton addTarget:self action:@selector(crossButtonClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _crossButton;
}

- (UIImageView *)goodImageView{
    if (!_goodImageView) {
        _goodImageView = [[UIImageView alloc] init];
    }
    return _goodImageView;
}

@end
